package cn.sciento.starter.lock;

import com.google.common.base.Objects;
import java.util.List;
import java.util.concurrent.TimeUnit;

public class LockInfo {
  private String name;
  
  private long waitTime;
  
  private long leaseTime;
  
  private TimeUnit timeUnit = TimeUnit.SECONDS;
  
  private List<String> keyList;
  
  public LockInfo() {}
  
  public LockInfo(String name, long waitTime, long leaseTime, TimeUnit timeUnit) {
    this.name = name;
    this.waitTime = waitTime;
    this.leaseTime = leaseTime;
    this.timeUnit = timeUnit;
  }
  
  public LockInfo(String name, List<String> keyList, long waitTime, long leaseTime, TimeUnit timeUnit) {
    this.name = name;
    this.keyList = keyList;
    this.waitTime = waitTime;
    this.leaseTime = leaseTime;
    this.timeUnit = timeUnit;
  }
  
  public String getName() {
    return this.name;
  }
  
  public void setName(String name) {
    this.name = name;
  }
  
  public long getWaitTime() {
    return this.waitTime;
  }
  
  public void setWaitTime(long waitTime) {
    this.waitTime = waitTime;
  }
  
  public long getLeaseTime() {
    return this.leaseTime;
  }
  
  public void setLeaseTime(long leaseTime) {
    this.leaseTime = leaseTime;
  }
  
  public TimeUnit getTimeUnit() {
    return this.timeUnit;
  }
  
  public void setTimeUnit(TimeUnit timeUnit) {
    this.timeUnit = timeUnit;
  }
  
  public List<String> getKeyList() {
    return this.keyList;
  }
  
  public void setKeyList(List<String> keyList) {
    this.keyList = keyList;
  }
  
  public boolean equals(Object o) {
    if (this == o)
      return true; 
    if (o == null || getClass() != o.getClass())
      return false; 
    LockInfo lockInfo = (LockInfo)o;
    return (this.waitTime == lockInfo.waitTime && this.leaseTime == lockInfo.leaseTime && 
      
      Objects.equal(this.name, lockInfo.name) && this.timeUnit == lockInfo.timeUnit && 
      
      Objects.equal(this.keyList, lockInfo.keyList));
  }
  
  public int hashCode() {
    return Objects.hashCode(new Object[] { this.name, Long.valueOf(this.waitTime), Long.valueOf(this.leaseTime), this.timeUnit, this.keyList });
  }
}
